﻿using System;

namespace DG.Common.Validation
{
    public class MethodValidator : ValidatorBase
    {
        private readonly Func<bool> _validationMethod;

        public MethodValidator(Func<bool> validationMethod, Func<string> errorMessage, Func<bool> preCondition)
            : base(errorMessage ?? (() => ""), preCondition)
        {
            _validationMethod = validationMethod;
        }

        public override Func<bool> ValidationMethod()
        {
            return _validationMethod;
        }
    }
}